using System;
using System.Collections;

namespace VCDepend.Engine
{
	public class ProjectStore : IEnumerable
	{
		private ArrayList m_projects;

		public ProjectStore()
		{
			m_projects = new ArrayList();
		}

		public void Add(Project p)
		{
			m_projects.Add(p);
		}

		public int Count
		{
			get
			{
				return m_projects.Count;
			}
		}

		public Project GetById(string projectId)
		{
			foreach(Project p in m_projects)
			{
				if (p.Id == projectId)
					return p;
			}

			return null;
		}

		public Project GetByName(string projectName)
		{
			foreach(Project p in m_projects)
			{
				if (p.Name == projectName)
					return p;
			}

			return null;
		}	

		public Project GetByOutputName(string outputName)
		{
			foreach(Project p in m_projects)
			{
				if (p.OutputName == outputName)
					return p;
			}

			return null;
		}	

		public IEnumerator GetEnumerator()
		{
			return m_projects.GetEnumerator();
		}
	}
}
